# -*- coding: utf-8 -*-
# @Author   : niejiali
# @Time     : 2019/1/8 16:51
# @File     : test002.py
# @Software : PyCharm
from http.client import HTTPException

from flask_script import iteritems

default_exceptions = {}
__all__ = ['HTTPException']


def _find_exceptions():
    for name, obj in iteritems(globals()):
        try:
            is_http_exception = issubclass(obj, HTTPException)
        except TypeError:
            is_http_exception = False
        if not is_http_exception or obj.code is None:
            continue
        __all__.append(obj.__name__)
        old_obj = default_exceptions.get(obj.code, None)
        if old_obj is not None and issubclass(obj, old_obj):
            continue
        default_exceptions[obj.code] = obj
_find_exceptions()

# del _find_exceptions